home *** CD-ROM | disk | FTP | other *** search
- /****
- * CIntelligentPanorama.c
- *
- * This class makes the Panorama a little more intelligent.
- *
- * Copyright © 1993 Quipus, by Mårten Sörliden. All rights reserved.
- *
- ****/
-
- #include <Global.h>
- #include <CIntelligentPanorama.h>
- #include <CIntelligentScrollPane.h>
-
-
- /** Construction and destruction methods **/
-
- void CIntelligentPanorama::IIntelligentPanorama(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing)
- {
- IPanorama(anEnclosure, aSupervisor, aWidth, aHeight,
- aHEncl, aVEncl, aHSizing, aVSizing);
- UseLongCoordinates(TRUE);
- autoScrolled = FALSE;
- autoRefresh = FALSE; // From CPane
- }
-
- void CIntelligentPanorama::Dispose(void)
- {
- LongRect theBounds;
-
- if (itsScrollPane)
- if (member(itsScrollPane, CIntelligentScrollPane)) {
- SetLongRect(&theBounds, 0L, 0L, 0L, 0L);
- SetBounds(&theBounds);
- }
- inherited::Dispose();
- }
-
-
- /** Accessing methods **/
-
- /* Override */
- void CIntelligentPanorama::SetBounds(LongRect *aBounds)
- {
- long hDelta = 0L;
- long vDelta = 0L;
-
- if ((aBounds->right < frame.right) && (aBounds->left < frame.left))
- hDelta = -Min(frame.right - aBounds->right, frame.left - aBounds->left);
- else if ((aBounds->right > frame.right) && (aBounds->left > frame.left))
- hDelta = Min(aBounds->right - frame.right, aBounds->left - frame.left);
- if ((aBounds->top < frame.top) && (aBounds->bottom < frame.bottom))
- vDelta = -Min(frame.top - aBounds->top, frame.bottom - aBounds->bottom);
- else if ((aBounds->top > frame.top) && (aBounds->bottom > frame.bottom))
- vDelta = Min(aBounds->top - frame.top, aBounds->bottom - frame.bottom);
- if (hDelta || vDelta)
- inherited::Scroll(hDelta, vDelta, TRUE);
- inherited::SetBounds(aBounds);
- if (itsScrollPane) {
- itsScrollPane->AdjustScrollMax();
- itsScrollPane->Calibrate();
- }
- }
-
-
- /** Drawing methods **/
-
- /* Override */
- void CIntelligentPanorama::ResizeFrame(register Rect *delta)
- {
- long hDelta = 0L;
- long vDelta = 0L;
-
- inherited::ResizeFrame(delta);
- if ((delta->right > 0L) && (frame.right > bounds.right) && (frame.left > bounds.left)) {
- hDelta = Min(delta->right, frame.right - bounds.right);
- hDelta = Min(hDelta, frame.left - bounds.left);
- }
- if ((delta->bottom > 0L) && (frame.bottom > bounds.bottom) && (frame.top > bounds.top)) {
- vDelta = Min(delta->bottom, frame.bottom - bounds.bottom);
- vDelta = Min(vDelta, frame.top - bounds.top);
- }
- if (hDelta || vDelta) {
- autoScrolled = TRUE;
- CPanorama::Scroll(-hDelta, -vDelta, FALSE);
- }
- }
-
-
- /** Size and location methods **/
-
- /* Override */
- void CIntelligentPanorama::ChangeSize(register Rect *delta, Boolean redraw)
- {
- LongRect oldAperture = aperture;
- Rect tmp;
-
- autoScrolled = FALSE; // Might be changed by ResizeFrame
- inherited::ChangeSize(delta, redraw);
- if (autoScrolled)
- if (SectLongRect(&aperture, &oldAperture, &oldAperture)) {
- FrameToQDR( &oldAperture, &tmp);
- InvalRect(&tmp);
- }
- }
-